package com.example.rememberpwd;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;
import java.util.Map;

public class SPsave {
    //保存账户密码到data.xml中
    public static boolean saveUserInfo(Context context,String account,String password){
        SharedPreferences sp = context.getSharedPreferences("data",context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putString("account",account);
        edit.putString("password",password);
        edit.commit();
        return true;
    }
//读取用户账号密码
    public static Map<String,String> getUserInfo(Context context){
        SharedPreferences sp = context.getSharedPreferences("data",context.MODE_PRIVATE);
        String account = sp.getString("account","");
        String password = sp.getString("password","");
        Map<String,String> userMap = new HashMap<>();
        userMap.put("account",account);
        userMap.put("password",password);
        return userMap;
    }

}
